#include "widget.h"
#include "ui_widget.h"
#include <QResizeEvent>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    // 设置label与Widget一样大
    ui->label->setGeometry(0,0,this->geometry().width(),this->geometry().height());
    pixmap = new QPixmap(":/doge.png");
    ui->label->setPixmap(*pixmap);
    // 将图片进行拉伸 与label大小一样大
    ui->label->setScaledContents(true);
}

void Widget::resizeEvent(QResizeEvent *event)
{
    qDebug() << event->size();
    ui->label->setGeometry(0,0,event->size().width(),event->size().height());
}

Widget::~Widget()
{
    delete ui;
    delete pixmap;
}

